import request from '@/utils/request'
//分页查询数据
export const GetSysUserPage = (searchObj, pageNum, pageSize) => {
  return request({
    url: `/admin/system/user/page/${pageNum}/${pageSize}`,
    method: 'get',
    //价格keyword的值转换为json对象提交：如果传入的keyword为'系统',会转换为{"keyword"}
    params: searchObj,
  })
}

//根据id删除用户
export const DeleteSysUser = id => {
  return request({
    url: `/admin/system/user/${id}`,
    method: 'delete',
  })
}
//添加用户
export const SaveSysUser = data => {
  return request({
    url: `/admin/system/user`,
    method: 'post',
    data,
  })
}

//根据id查询用户
export const GetSysUserById = id => {
  return request({
    url: `/admin/system/user/${id}`,
    method: 'get',
  })
}
//更新用户
export const UpdateSysUser = data => {
  return request({
    url: `/admin/system/user`,
    method: 'put',
    data,
  })
}
//文件上传
export const FileUpload = data => {
  return request({
    url: `/admin/system/fileUpload`,
    method: 'post',
    data,
  })
}
//给用户分配角色请求
export const AssignRoleToUser = (userId, roleIds) => {
  return request({
    url: `/admin/system/userRole/assignRoles?userId=${userId}&roleIds=${roleIds}`,
    method: 'put',
  })
}
